package com.csjy.migration.hnnd.workflow;

import com.csjy.migration.hnnd.DbUtil;
import com.csjy.migration.hnnd.ProgramArgument;
import com.csjy.migration.hnnd.Tool;
import com.csjy.migration.hnnd.annotation.Task;
import com.csjy.migration.hnnd.business.BpmResponsibilityRepayment;
import com.csjy.migration.hnnd.business.NdBpmResponsibilityLoan;
import com.csjy.migration.hnnd.business.SourceBusinessData;
import com.fasterxml.jackson.core.JsonProcessingException;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 登记项目还款
 *   此类流程只会创建还款记录，所以还需要通过还款记录找到对应的放款记录
 */
public class ItemReturnAccountHny extends WorkflowMigration {

  private NdBpmResponsibilityLoan ndBpmResponsibilityLoan = null;
  private BpmResponsibilityRepayment bpmResponsibilityRepayment = null;

  public ItemReturnAccountHny(DbUtil sourceDbUtil, DbUtil targetDbUtil, SourceBusinessData sourceData, ProgramArgument programArgument, String projectId, String procInstId, Map procInstRow) throws Exception {
    super(sourceDbUtil, targetDbUtil, sourceData, programArgument, projectId, procInstId, procInstRow);
    this.customInitData();
  }

  @Override
  public void customInitData() throws SQLException {
    this.ndBpmResponsibilityLoan = new NdBpmResponsibilityLoan(sourceDbUtil, targetDbUtil, sourceData, programArgument, projectId, procInstId,false);
    this.bpmResponsibilityRepayment = new BpmResponsibilityRepayment(sourceDbUtil, targetDbUtil, sourceData, programArgument, projectId, procInstId);
  }

  @Override
  public void customInsertOrUpdateData() throws Exception {
    this.ndBpmResponsibilityLoan.start();
    this.bpmResponsibilityRepayment.start();
  }

  @Task("登记项目还款@项目经理登记还款")
  public void xmjldjhk() throws Exception {
    this.curModelMap.put("all", new String[]{"task1562633332994tg","通过"});
    this.setCommonData(true,null);
    this.ndBpmResponsibilityLoan.getTaskParamMap().put(curJbpmTaskInstanceId, this.initTaskParamMap());
    this.bpmResponsibilityRepayment.getTaskParamMap().put(curJbpmTaskInstanceId, this.initTaskParamMap());
  }

  @Task("登记项目还款@综合人员复核台账")
  public void zhryfhtz() throws Exception {
    this.curModelMap.put("通过", new String[]{"endtg","通过"});
    this.setCommonData(true,null);
    this.bpmResponsibilityRepayment.getTaskParamMap().put(curJbpmTaskInstanceId, this.initTaskParamMap());
  }
}
